<?php

namespace app\common\model;

use think\model\concern\SoftDelete;

class ApikeyLibrary extends \think\Model
{
    use SoftDelete;

    protected $table = 'db_apikey_library';

    protected $jsonAssoc = true;

    protected $autoWriteTimestamp = true;

    protected $schema = [
        'id' => 'int',
        'create_time' => 'int',
        'update_time' => 'int',
        'delete_time' => 'int',
        'pubid' => 'varchar',
        'name' => 'varchar',
        'state' => 'tinyint',
        'usage_time' => 'int',
        'end_time' => 'int',
        'end_reason' => 'varchar',
        'belonging_account' => 'varchar',
    ];

    public $getters = [
        
    ];

    /**
     * 使用时间设置器
     */
    public function setUsageTimeAttr($value, $data)
    {
        return $value?strtotime($value):0;
    }

    /**
     * 结束时间设置器
     */
    public function setEndTimeAttr($value, $data)
    {
        return $value?strtotime($value):0;
    }
}
